package cn.wolfcode.trip.base.domain;


import com.alibaba.druid.support.json.JSONUtils;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * 大攻略 实体类
 */
@Setter
@Getter
public class Strategy extends  BaseDomain {

    //状态常量
    public static final int STATE_NOMAL =0;//普通
    public static final int STATE_HOT =1;//推荐
    public static final int STATE_DISABEL =-1;//禁用

    //地区
    private Region place;
    //攻略标题
    private String title;
    //攻略副标题
    private String subTitle;
    //背景图
    private String coverUrl;
    //状态
    private Integer state=STATE_NOMAL;

    //状态形容词
    public String getStateName(){
        String str="";
        if(state==STATE_NOMAL){
            str="普通";
        }else if(state==STATE_HOT){
            str="推荐";
        }else {
            str="禁用";
        }
        return str;
    }

    //json字符串
    public String getJsonString(){
        Map<String,Object> map=new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("subTitle",subTitle);
        if (place!=null){
            map.put("placeId",place.getId());
        }
        map.put("coverUrl",coverUrl);
        map.put("state",state);
        return JSONUtils.toJSONString(map);
    }
}